From 68538958cf79696d3f0a94079b0966aaff09d060 Mon Sep 17 00:00:00 2001 From: robertl Date: Sat, 23 Jul 2005 05:23:13 +0000 Subject: [PATCH] Tobias Belgabor contributes filter for selection points based on DOP. --- gpsbabel/Makefile | 2 +- gpsbabel/README | 44 +++++++++- gpsbabel/dopfilt.c | 147 ++++++++++++++++++++++++++++++++ gpsbabel/filter_vecs.c | 6 ++ gpsbabel/style/openoffice.style | 3 +- 5 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 gpsbabel/dopfilt.c diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 87bb71a9a..b36a46c41 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -38,7 +38,7 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \ vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \ tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o -FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o trackfilter.o +FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o trackfilter.o dopfilt.o OSJEEPS=jeeps/gpslibusb.o JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \ diff --git a/gpsbabel/README b/gpsbabel/README index e50d9331f..ba814f9d7 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -464,6 +464,12 @@ THE FORMATS GpsDrive way.txt file format. A space seperated format file. Tested against GpsDrive v 1.30 found @ http://www.kraftvoll.at/software. Contributed by Alan Curry. + + GPSDRIVETRACK + + Format used by GpsDrive to save tracks. Like GPSDRIVE a space + seperated format file. See above for a link to GpsDrive. + Contributed by Tobias Minich. Geocaching DB @@ -905,7 +911,15 @@ THE FORMATS -i gpx -f in.gpx -o bcr,index=1,name="From A to B",radius=6371012 \ -F a_to_b.bcr - + + OPENOFFICE + Tab seperated export-all (except geocahing data) file format. + Intended to serve as source for number-processing applications + like OpenOffice, Ploticus and others. Tab was chosen as delimiter + because it is a) supported by both OpenOffice and Ploticus and + b) is not ',', so you can use 'sed -i "s/./,/g" .csv' to adapt it to + locales where ',' is used as decimal seperator. + Contributed by Tobias Minich. DATA FILTERS @@ -1251,3 +1265,31 @@ DATA FILTERS -i gpx -f in.gpx \ -x track,pack,split=4h,title="LOG # %c" \ -o gpx -F out.gpx + + DOP + + This filter 'fixes' gps data by discarding points with a hdop + and/or vdop over a set limit. If you give both the hdop and a + vdop options, by default points that exceed EITHER are discarded + (OR). This filter processes waypoints, tracks, and routes. + + HDOP (float) + + Points with a hdop exceeding the given value are discarded. + + VDOP (float) + + Points with a vdop exceeding the given value are discarded. + + HDOPANDVDOP + + Only useful if both hdop and vdop are given. Now logical AND + is used, i.e. only points exceeding both given values are + discarded. + + Example: gpsbabel \ + -i gpx -f in.gpx \ + -x fix,hdop=10,vdop=20,hdopandvdop \ + -o gpx -F out.gpx + + Contributed by Tobias Minich. diff --git a/gpsbabel/dopfilt.c b/gpsbabel/dopfilt.c new file mode 100644 index 000000000..a4594684a --- /dev/null +++ b/gpsbabel/dopfilt.c @@ -0,0 +1,147 @@ +/* + Suppress points based on high Degree of Precision (DOP) values. + + Copyright (C) 2005 Robert Lipe, robertlipe@usa.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ +#include +#include "defs.h" + +extern queue waypt_head; + +static char *hdopopt = NULL; +static char *vdopopt = NULL; +static char *andopt = NULL; +static double hdopf; +static double vdopf; + +static +arglist_t fix_args[] = { + {"hdop", &hdopopt, "Suppress waypoints with higher hdop", + "-1.0", ARGTYPE_BEGIN_REQ | ARGTYPE_FLOAT}, + {"vdop", &vdopopt, "Suppress waypoints with higher vdop", + "-1.0", ARGTYPE_END_REQ | ARGTYPE_FLOAT}, + {"hdopandvdop", &andopt, "Link hdop and vdop supression with AND", + NULL, ARGTYPE_BOOL}, + {0, 0, 0, 0, 0} +}; + +static void +fix_process_track(const route_head *trk) +{ + waypoint * waypointp; + queue *elem, *tmp; + + QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) { + + int del = 0; + int delh = 0; + int delv = 0; + + waypointp = (waypoint *)elem; + + if ((hdopf >= 0.0) && (waypointp->hdop > hdopf)) + delh = 1; + if ((vdopf >= 0.0) && (waypointp->vdop > vdopf)) + delv = 1; + + if (andopt) + del = delh && delv; + else + del = delh || delv; + + if (del) { + waypt_del(waypointp); + waypt_free(waypointp); + } + + } +} + +void +fix_process(void) +{ + waypoint * waypointp; + + int tc = track_count(); + int rc = route_count(); + + queue *elem, *tmp; + extern queue waypt_head; + + // Filter waypoints + + QUEUE_FOR_EACH(&waypt_head, elem, tmp) { + + int del = 0; + int delh = 0; + int delv = 0; + + waypointp = (waypoint *)elem; + + if ((hdopf >= 0.0) && (waypointp->hdop > hdopf)) + delh = 1; + if ((vdopf >= 0.0) && (waypointp->vdop > vdopf)) + delv = 1; + + if (andopt) + del = delh && delv; + else + del = delh || delv; + + if (del) { + waypt_del(waypointp); + waypt_free(waypointp); + } + + } + + // Filter tracks + if (tc > 0) + track_disp_all(fix_process_track, NULL, NULL); + + // And routes + if (rc > 0) + route_disp_all(fix_process_track, NULL, NULL); + +} + +void +fix_init(const char *args) +{ + if (hdopopt) + hdopf = atof(hdopopt); + else + hdopf = -1.0; + if (vdopopt) + vdopf = atof(vdopopt); + else + vdopf = -1.0; +} + +void +fix_deinit(void) +{ +} + +filter_vecs_t fix_vecs = { + fix_init, + fix_process, + fix_deinit, + NULL, + fix_args +}; diff --git a/gpsbabel/filter_vecs.c b/gpsbabel/filter_vecs.c index 646f486e5..8531911d9 100644 --- a/gpsbabel/filter_vecs.c +++ b/gpsbabel/filter_vecs.c @@ -38,6 +38,7 @@ extern filter_vecs_t reverse_route_vecs; extern filter_vecs_t sort_vecs; extern filter_vecs_t stackfilt_vecs; extern filter_vecs_t trackfilter_vecs; +extern filter_vecs_t fix_vecs; static fl_vecs_t filter_vec_list[] = { @@ -91,6 +92,11 @@ fl_vecs_t filter_vec_list[] = { "track", "Manipulate track lists" }, + { + &fix_vecs, + "dop", + "Remove unreliable points with high hdop or vdop." + }, { NULL, NULL, diff --git a/gpsbabel/style/openoffice.style b/gpsbabel/style/openoffice.style index b39a179cf..ea42b7f9d 100644 --- a/gpsbabel/style/openoffice.style +++ b/gpsbabel/style/openoffice.style @@ -6,14 +6,13 @@ # # -DESCRIPTION Custom "Everything" Style +DESCRIPTION Tab delimitered csv useful for OpenOffice, Ploticus etc. # FILE LAYOUT DEFINITIIONS: # FIELD_DELIMITER TAB RECORD_DELIMITER NEWLINE BADCHARS TAB -FORMAT_TYPE INTERNAL # # HEADER STUFF: -- 2.30.2